//
//  TimeMenuPageView.m
//  SAYAKA_Table
//
//  Created by numanuma08 on 2013/07/20.
//  Copyright (c) 2013年 勘米良. All rights reserved.
//

#import "TileMenuPageView.h"
#import <QuartzCore/QuartzCore.h>

@implementation TileMenuPageView
@synthesize thumbnailAreaView1 = _thumbnailAreaView1;
@synthesize thumbnailAreaView2 = _thumbnailAreaView2;
@synthesize thumbnailAreaView3 = _thumbnailAreaView3;
@synthesize thumbnailAreaView4 = _thumbnailAreaView4;
@synthesize thumbnailAreaView5 = _thumbnailAreaView5;
@synthesize thumbnailAreaView6 = _thumbnailAreaView6;
@synthesize category = _category;
@synthesize delegate;

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
    }
    return self;
}

+ (id)tileMenuPageView
{
    UINib *nib = [UINib nibWithNibName:@"TileMenuPageView" bundle:nil];
    ItemThumbnailView *view = [[nib instantiateWithOwner:self options:nil] objectAtIndex:0];
    return view;
}

//- (void)setItemThumbnail:(UIImage*)image name:(NSString*)name price:(NSString*)price
//             description:(NSString*)description number:(NSInteger)number
- (void)setItemThumbnail:(Item *)item number:(NSInteger)number
{
    UIView *thumbnailAreaView;
    ItemThumbnailView *addView = [ItemThumbnailView itemThumbnailView];
    
    switch (number) {
        case 1:
            thumbnailAreaView = _thumbnailAreaView1;
            _itemThunbnailView1 = addView;
            break;
        case 2:
            thumbnailAreaView = _thumbnailAreaView2;
            _itemThunbnailView2 = addView;
            break;
        case 3:
            thumbnailAreaView = _thumbnailAreaView3;
            _itemThunbnailView3 = addView;
            break;
        case 4:
            thumbnailAreaView = _thumbnailAreaView4;
            _itemThunbnailView4 = addView;
            break;
        case 5:
            thumbnailAreaView = _thumbnailAreaView5;
            _itemThunbnailView5 = addView;
            break;
        case 6:
            thumbnailAreaView = _thumbnailAreaView6;
            _itemThunbnailView6 = addView;
            break;
        default:
            return;
    }
//    addView.image = image;
//    addView.priceLabel.text = [NSString stringWithFormat:@"%@円", item.price];
//    addView.descriptionLabel.text = item.comment;
    //[addView startAutoScroll];
    addView.item = item;
    addView.layer.shadowColor = [[UIColor blackColor] CGColor];
    addView.layer.shadowOpacity = 0.5;
    addView.layer.shadowOffset = CGSizeMake(2.5, 2.5);
    addView.delegate = self;
    
    [thumbnailAreaView addSubview:addView];
}

- (void)startAutoScrollAllThumnbnail
{
    [_itemThunbnailView1 startAutoScroll];
    [_itemThunbnailView2 startAutoScroll];
    [_itemThunbnailView3 startAutoScroll];
    [_itemThunbnailView4 startAutoScroll];
    [_itemThunbnailView5 startAutoScroll];
    [_itemThunbnailView6 startAutoScroll];
}

- (void)itemThumbnailViewDidTouchUpInside:(ItemThumbnailView *)view
{
    if ([self.delegate respondsToSelector:@selector(tileMenuPageView:didSelectItem:)]) {
        [self.delegate tileMenuPageView:self didSelectItem:view.item];
    }
}

@end
